package com.fqgj.sentry.policy.engine.domain;

import com.fqgj.common.utils.JSONUtils;
import com.fqgj.sentry.policy.engine.domain.enums.ConditionGroupComposeEnum;
import com.fqgj.sentry.policy.engine.domain.enums.RuleTypeEnum;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * Created by kennykong on 2017/7/15.
 */
public class Rule implements Serializable {

    /**
     * 规则ID
     */
    private Long ruleId;

    /**
     * 规则名称
     */
    private String ruleName;

    /**
     * 规则种类：策略规则|策略前置规则
     */
    private RuleTypeEnum ruleType;

    /**
     * 规则的顺序
     */
    private Integer order;

    /**
     * 击中之后的决策：拒绝|接受|人工审核
     */
    private Decision hitDecisionOption;

    /**
     * 权重相关信息，包括：计算方式，结果分等
     */
    private Weight weight;

    /**
     * 条件组之间的组合方式：满足所有|满足任意|任一不满足|均不满足
     */
    private ConditionGroupComposeEnum conditionGroupCompose;
    /**
     * 条件组集合
     */
    private List<ConditionGroup> conditionGroups;

    /**
     * 规则返回结果
     */
    private RuleResult ruleResult;


    public Long getRuleId() {
        return ruleId;
    }

    public Rule setRuleId(Long ruleId) {
        this.ruleId = ruleId;
        return this;
    }

    public String getRuleName() {
        return ruleName;
    }

    public Rule setRuleName(String ruleName) {
        this.ruleName = ruleName;
        return this;
    }

    public ConditionGroupComposeEnum getConditionGroupCompose() {
        return conditionGroupCompose;
    }

    public Rule setConditionGroupCompose(ConditionGroupComposeEnum conditionGroupCompose) {
        this.conditionGroupCompose = conditionGroupCompose;
        return this;
    }

    public RuleTypeEnum getRuleType() {
        return ruleType;
    }

    public Rule setRuleType(RuleTypeEnum ruleType) {
        this.ruleType = ruleType;
        return this;
    }

    public Decision getHitDecisionOption() {
        return hitDecisionOption;
    }

    public Rule setHitDecisionOption(Decision hitDecisionOption) {
        this.hitDecisionOption = hitDecisionOption;
        return this;
    }

    public Weight getWeight() {
        return weight;
    }

    public Rule setWeight(Weight weight) {
        this.weight = weight;
        return this;
    }

    public RuleResult getRuleResult() {
        return ruleResult;
    }

    public Rule setRuleResult(RuleResult ruleResult) {
        this.ruleResult = ruleResult;
        return this;
    }

    public List<ConditionGroup> getConditionGroups() {
        return conditionGroups;
    }

    public Rule setConditionGroups(List<ConditionGroup> conditionGroups) {
        this.conditionGroups = conditionGroups;
        return this;
    }

    public Integer getOrder() {
        return order;
    }

    public Rule setOrder(Integer order) {
        this.order = order;
        return this;
    }

    public static void main(String[] args) {
        Weight weight = new Weight();
        weight.setParams(Arrays.asList("10,0"));
        weight.setVariable(null);
        weight.setWeightExpression("weightScore");
        try {
            System.out.println(JSONUtils.obj2json(weight));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
